﻿using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using System;
using System.Collections.Generic;

namespace BeatingMole
{
    class CBusOrtherSettings
    {
        #region "Variable"
        CInfoButtonOrthers InfoButtonOrthers;
        ContentManager _Content;
        bool IsClick = false;
        MouseState MouseCur;
        MouseState MousePre;
        #endregion

        #region "Properties"

        #endregion

        #region "Constructor"
        public CBusOrtherSettings(ContentManager content)
        {
            _Content = content;
            InfoButtonOrthers = new CInfoButtonOrthers(_Content);
        }
        #endregion

        #region "Method"
        public void IsClickPause(Dictionary<String, Rectangle> DIRectangle)
        {
            // Dùng Biến CGlobal bị lỗi , tạm thời dùng cách khác.
            MouseCur = Mouse.GetState();
            if (MouseCur.LeftButton == ButtonState.Pressed && MousePre.LeftButton == ButtonState.Released)
            {
                Rectangle BtnGamePause = new Rectangle(650, 0, DIRectangle["start"].Width, DIRectangle["start"].Height);
                if (BtnGamePause.Contains(new Point((int)Mouse.GetState().X, (int)Mouse.GetState().Y)))
                {
                    if (CGlobalVariable.IsPauseGame == false)
                    {
                        CGlobalVariable.IsPauseGame = true;
                        IsClick = true;                        
                    }
                    else if (IsClick == true)
                    {
                        CGlobalVariable.IsPauseGame = false;
                        IsClick = false;                        
                    }
                }
            }
            //CGlobalVariable.mouseStatePrevious = CGlobalVariable.mouseStateCurrent;
            MousePre = MouseCur;
        }

        public void UpdateButtonOrthers(GameTime gameTime)
        {
            IsClickPause(InfoButtonOrthers.XmlSpriteBatch);
        }

        public void DrawUpdateButtonOrthers(SpriteBatch spriteBatch)
        {
            if (CGlobalVariable.IsPauseGame == false)
            {
                spriteBatch.Draw(InfoButtonOrthers.SpriteBatch, new Vector2(650, 0), InfoButtonOrthers.XmlSpriteBatch["start"], Color.White);
            }
            else
            {
                spriteBatch.Draw(InfoButtonOrthers.SpriteBatch, new Vector2(650, 0), InfoButtonOrthers.XmlSpriteBatch["pause"], Color.White);
            }
        }
        #endregion
    }
}
